
typedef enum{
    SENDER_A,
    SENDER_B
} EN_SENDER_TYPE;

class SenderBase{
public:
    virtual void send() = 0;
    virtual  ~SenderBase(){}
};

class SenderA: public SenderBase{
public:
    void send(){
        printf("call SenderA to send.\n");
    }
};

class SenderB: public SenderBase{
public:
    void send(){
        printf("call SenderB to send.\n");
    }
};


/*
普通工厂模式
*/
class Facotry_Normal{
public:
    static SenderBase* CreateSender(EN_SENDER_TYPE type){
        if(type == SENDER_A)
        {
            return new SenderA();
        }
        else if(type == SENDER_B)
        {
            return new SenderB();
        }
        else
        {
            printf("CreaterSender fail, Unknown type:%d.\n", type);
            return nullptr;
        }
    }
};

/*
静态工厂方法模式
*/
class Facotry_Multi{
public:
    static SenderBase* CreaterSenderA()
    {
        return new SenderA();
    }

    static SenderBase* CreaterSenderB()
    {
        return new SenderB();
    }
};

/*
抽象工厂模式
*/
class Factory_Base{
public:
    virtual SenderBase* CreateFactory() = 0;
    virtual ~Factory_Base() {}
};

class Factory_SenderA : public Factory_Base{
public:
    SenderBase* CreateFactory(){
        return new SenderA();
    }
};

class Factory_SenderB : public Factory_Base{
public:
    SenderBase* CreateFactory(){
        return new SenderB();
    }
};